home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / elleu (IT).ifs < prev    next >
Text File  |  2005-02-03  |  8KB  |  285 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=06.10.2004 Stefano Mora stefano.mora@libero.it
  8. Title=Elleu
  9. Description=Get movie info from elleu.it
  10. Site=http://www.elleu.com
  11. Language=IT
  12. Version=1.0.1 02.02.2005
  13. Requires=3.5.0
  14. Comments=**Chages**|Modified by Dino Librandi dinolib@libero.it (2005) for v 3.5.0
  15. License=The source code of the script can |be used in another program only |if full credits to script author and |a link to Ant Movie Catalog website |are given in the About box or in the |documentation of the program
  16. GetInfo=1
  17.  
  18. [Options]
  19.  
  20. ***************************************************)
  21.  
  22. program elleu;
  23.  
  24. var
  25.  MovieName: string;
  26.  
  27. const
  28.   PATHLOG = 'c:\Programmi\Ant Movie Catalog\Log\LogElleu\';
  29.   SITE = 'http://www.elleu.com';
  30.   FILMURL = SITE+'/customer/';
  31.   MOVIE = 'Il commissario Montalbano - La gita a Tindari (Dvd)';
  32.  
  33. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  34. var
  35.   i: Integer;
  36. begin
  37.   result := -1;
  38.   if StartAt < 0 then
  39.     StartAt := 0;
  40.   for i := StartAt to List.Count-1 do
  41.     if Pos(Pattern, List.GetString(i)) <> 0 then
  42.     begin
  43.       result := i;
  44.       Break;
  45.     end;
  46. end;
  47.  
  48. // --------------------------------------------------
  49.  
  50. // Analizza la pagina e ricava i dati
  51. procedure LeggeFilm(Page: TStringList);
  52. var
  53.   strTmp, strTmp2, strTmp3: string;
  54.   LineNr: integer;
  55.   EndLine: integer;
  56.   BeginPos, EndPos: Integer;
  57.   bNome: boolean;
  58.   
  59. begin
  60.  
  61. // Titoli
  62.   LineNr := FindLine('Titolo', Page, 0);
  63.   strTmp := Page.GetString(LineNr);
  64.   // I dati sono tutti in questa riga !
  65.  
  66. // Immagine - fascetta
  67.   BeginPos := pos('fascette', strTmp)-15;
  68.   delete( strTmp, 1, BeginPos);
  69.   BeginPos := 0;
  70.   EndPos := pos('width', strTmp)-2;
  71.   strTmp2 := SITE+copy( strTmp, BeginPos, EndPos-BeginPos);
  72.   GetPicture(strTmp2);
  73.   //ShowMessage(strTmp2);
  74.  
  75. // Titolo
  76.   BeginPos := pos('Titolo', strTmp);
  77.   delete( strTmp, 1, BeginPos+13);
  78.   //ShowMessage(strTmp);
  79.   BeginPos := 0;
  80.   EndPos := pos('<br>', strTmp)-1;
  81.   strTmp2 := trim(copy(strTmp, BeginPos, EndPos));
  82.   // Toglie il (dvd) o (vhs)
  83.   BeginPos := pos('(Dvd)', strTmp2);
  84.   if BeginPos <> 0 then strTmp2 := trim(copy (strTmp2, 1, BeginPos-1));
  85.   BeginPos := pos('(Vhs)', strTmp2);
  86.   if BeginPos <> 0 then strTmp2 := trim(copy (strTmp2, 1, BeginPos-1));
  87.   // Titolo originale === titolo tradotto
  88.   SetField( fieldTranslatedTitle, strTmp2);
  89.   SetField( fieldOriginalTitle, strTmp2);
  90.   //ShowMessage(strTmp2);
  91.  
  92. // Attori
  93.   BeginPos := pos('Attori:', strTmp);
  94.   delete( strTmp, 1, BeginPos+13);
  95.   BeginPos := 0;
  96.   EndPos := pos('<br>', strTmp)-1;
  97.   strTmp2 := copy(strTmp, BeginPos, EndPos);
  98.   SetField( fieldActors, strTmp2);
  99.   //ShowMessage(strTmp2);
  100.  
  101. // Regia
  102.   BeginPos := pos('Regia:', strTmp);
  103.   delete( strTmp, 1, BeginPos+13);
  104.   BeginPos := 0;
  105.   EndPos := pos('<br>', strTmp)-1;
  106.   strTmp2 := trim(copy(strTmp, BeginPos, EndPos));
  107.   SetField( fieldDirector, strTmp2);
  108.  
  109. // Genere
  110.   BeginPos := pos('Genere:', strTmp);
  111.   delete( strTmp, 1, BeginPos+13);
  112.   BeginPos := 0;
  113.   EndPos := pos('<br>', strTmp)-1;
  114.   strTmp2 := copy(strTmp, BeginPos, EndPos);
  115.   SetField( fieldCategory, trim(strTmp2));
  116.  
  117. // Durata
  118.   BeginPos := pos('Durata:', strTmp);
  119.   delete( strTmp, 1, BeginPos+13);
  120.   BeginPos := 0;
  121.   EndPos := pos('min', strTmp)-1;
  122.   strTmp2 := trim(copy(strTmp, BeginPos, EndPos));
  123.   SetField( fieldLength, trim(strTmp2));
  124.  
  125. // Anno
  126.   BeginPos := pos('Anno di p', strTmp);
  127.   if BeginPos = 0 then  // Non trovato -> linea successiva !
  128.     begin
  129.     strTmp := Page.GetString(LineNr+1);
  130.     BeginPos := pos('Anno di p', strTmp);
  131.     end
  132.   delete( strTmp, 1, BeginPos+34);
  133.   BeginPos := 0;
  134.   EndPos := pos('<br>', strTmp)-1;
  135.   strTmp2 := trim(copy(strTmp, BeginPos, EndPos));
  136.   SetField( fieldYear, strTmp2);
  137.  
  138. // Descrizione
  139.   BeginPos := pos('>Trama<', strTmp);
  140.   delete (strTmp, 1, BeginPos);
  141.  
  142.   BeginPos := pos('class="testo"', strTmp)+30;
  143.   delete (strTmp, 1, BeginPos);
  144.  
  145.   BeginPos := 0;
  146.   EndPos := pos('</td>', strTmp)-1;
  147.  
  148.   strTmp2 := copy( strtmp, BeginPos, EndPos-BeginPos);
  149.   HTMLRemoveTags(strTmp2);
  150.   SetField( fieldDescription, strTmp2);
  151.  
  152.   // Si sposta nella pagina dei risultati
  153.   //DisplayResults;
  154. end;
  155.  
  156. // ---
  157.  
  158. procedure AnalyzePage(Address: string);
  159.  
  160. var
  161.   Page: TStringList;
  162.   strPage, MovieAddr, MovieTitle : string;
  163.   BeginPos, EndPos: Integer;
  164.   
  165.   LineNr: Integer;
  166.   rigalista: string;
  167.   rigahtml: string;
  168.   strTmp: string;
  169.   altrapagina: string;
  170.  
  171. begin
  172.   // Crea la lista
  173.   Page:= TStringList.Create;
  174.   
  175.   // Riceve la pagina
  176.   Page.Text := GetPage(Address);
  177.   //Page.SaveToFile(PATHLOG+MovieName+'.res');
  178.   //Page.LoadFromFile(PATHLOG+MOVIE+'.res');
  179.  
  180.   BeginPos:= FindLine('Nessun film trovato', Page, 0);
  181.   if BeginPos <> -1 then
  182.     begin
  183.     ShowMessage('Film non trovato !');
  184.     exit;
  185.     end;
  186.  
  187.   // Controllare che ci siano film !!
  188.   LineNr := FindLine('Prodotti trovati', Page, 0);
  189.   if(LineNr = -1) then
  190.     begin
  191.     // Trovato il film
  192.     // LeggeFilm(Page);
  193.     ShowMessage('Nessuna voce trovata');
  194.     end
  195.  
  196.   else  // Lista di film
  197.  
  198.     begin
  199.  
  200.     PickTreeClear;
  201.     PickTreeAdd('Risultati ricerca per "' + MovieName + '":', '');
  202.  
  203.     LineNr := FindLine('>Titolo<', Page, LineNr);
  204.     while LineNr <> -1 do
  205.       begin
  206.  
  207. // Titolo
  208.       rigahtml:= Page.GetString(LineNr);
  209.  
  210.       // Url
  211.       BeginPos:= pos('href=', rigahtml);
  212.       Delete(rigahtml, 1, BeginPos);
  213.  
  214.       BeginPos := 5;
  215.       EndPos:= pos(' class="te', rigahtml);
  216.       MovieAddr:= FILMURL+copy( rigahtml, BeginPos, EndPos-BeginPos);
  217.  
  218.       BeginPos:= pos('">', rigahtml)+2;
  219.       EndPos:= pos('</a>', rigahtml);
  220.       MovieTitle:= copy( rigahtml, BeginPos, EndPos-BeginPos);
  221.  
  222.       // Legge il regista
  223.       LineNr := FindLine('Regista:', Page, LineNr);
  224.       if LineNr <> -1 then
  225.         begin
  226.         strTmp := Page.GetString(LineNr);
  227.         BeginPos := pos('</span>', strTmp)+7;
  228.         EndPos := 1000;
  229.         strTmp := trim(copy(strTmp, BeginPos, EndPos-BeginPos));
  230.         MovieTitle := MovieTitle + ' - ' + strTmp;
  231.         end
  232.  
  233.       // Add to listbox
  234.       PickTreeAdd(MovieTitle, MovieAddr);
  235.  
  236.       // Restart the process
  237.       LineNr := LineNr+2;
  238.       LineNr := FindLine('>Titolo<', Page, LineNr);
  239.       end;
  240.  
  241.       // Controlla se ci sono altre pagine di risultati
  242.       LineNr := FindLine('>Avanti<', Page, LineNr);
  243.       if LineNr <> -1 then
  244.         begin
  245.         PickTreeAdd('Ci sono altre pagine risultato ...', '');
  246.         
  247.         // Estrae l'indirizzo per un'altra pagina
  248.         strTmp := Page.GetString(LineNr);
  249.         BeginPos := pos('href="', strTmp)+6;
  250.         EndPos := pos('" id=', strTmp);
  251.         altrapagina := copy( strTmp, BeginPos, EndPos-BeginPos);
  252.         //ShowMessage(altrapagina);
  253.         end;
  254.  
  255.       // Visualizza la lista e fa scegliere
  256.       if(PickTreeExec(Address)) then
  257.         begin
  258.         Page.text := GetPage(Address);
  259.         // Salva la pagina per debug
  260.             //Page.SaveToFile(PATHLOG+MovieName+'.film');
  261.             //Page.LoadFromFile(PATHLOG+MOVIE+'.film');
  262.         LeggeFilm(Page);
  263.         end;
  264.     end;
  265.   Page.Free();
  266. end;
  267.  
  268. // -------------------- main
  269.  
  270. begin
  271.   if CheckVersion(3,5,0) then
  272.   begin
  273.     // Considera il titolo tradotto, se vuoto il titolo originale
  274.     MovieName := GetField(fieldTranslatedTitle);
  275.     if MovieName = '' then MovieName := GetField(fieldOriginalTitle);
  276.     // Chiede conferma del titolo
  277.     Input('elleu Import', 'Titolo del film:', MovieName);
  278.     if MovieName <> '' then
  279.     begin
  280.       AnalyzePage('http://www.elleu.com/customer/search.php?substring='+UrlEncode(MovieName)+'&vers=DVD&showhow=simple&catebig%5B%5D=DVD&catebig%5B%5D=VHS&catebig%5B%5D=LIBRI&catebig%5B%5D=CD&ordersearch=add_date&typesearch=minisearch');
  281.     end;
  282.   end else
  283.     ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
  284. end.
  285.